<?php slot('worry','now'); ?>
<div class="Cw1280">
        <!--成长烦恼-->
        <div class="Czfn_div">
            <div class="DetitleCt"><?php echo $worry->getTitle(); ?></div>
            <div class="Debianqian">
                <?php foreach($worry->getTagsArray() as $tag): ?>
                <li><?php echo $tag ?></li>
                <?php endforeach; ?>
            </div>
            <div class="Delistd bgno">
            	<div class="Delistdc">
                    <div class="Depto"><img src="<?php echo $worry->getAuthorCover(); ?>" width="38" height="38"></div>
                    <div class="DeBcont">
                        <div class="Deuntx" style="padding-top:0px;"><strong><?php echo $worry->getAuthorName(); ?></strong> | <span><?php echo $worry->getAuthorCity(); ?>&nbsp;<?php echo $worry->getAuthorChildrenInfo(); ?>&nbsp;&nbsp;问到：
                            </span></div>
                        <div class="Deuntx"><span style="color:#808080;">Ta 描述的烦恼：</span></div>
                        <div class="Decntx">
                            <p>
                                <?php echo $worry->getContent(); ?>
                            </p>
                        </div>
                        <?php if($worry->getUserId() == $sf_user->getAttribute('user_id')): ?>
                        <div class="Debianqian"><a href="javascript:void(0);" onClick="layerOper('<?php echo url_for('worry/edit?id='.$worry->getId()); ?>')" >修改</a></div>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="DePlx"><span><?php echo $worry->getAnswerNum(); ?> 个回答</span><span style="padding-left:40px;"><?php echo $worry->getCommentNum(); ?> 条评论</span></div>
            </div>
            
            <?php include_component('worry', 'answer_list',array('worry'=>$worry)); ?>
            <div class="Delistd bgno pb10">
               <?php if(!$sf_user->isAuthenticated()): ?>
                    <div class="DeFlinksF">
                        <h1><a href="#">解答</a></h1>
                        <form action="<?php echo url_for('worry/create_answer'); ?>" method="post" class="HuiForm" onSubmit="return CheckForm();">
                            <textarea name="content" id="content-t"></textarea>
                            <input type="hidden" name="worry_id" value="<?php echo $worry->getId(); ?>" />
                            <input type="submit" value="回复">
                        </form>
                    </div>
                <?php else: ?>
                    <?php if($worry->getUserId() != $sf_user->getAttribute('user_id')): ?>
                        <?php if(!WorryAnswerTable::hasAnswer($sf_user->getAttribute('user_id'), $worry->getId())): ?>
                        <div class="DeFlinksF">
                            <h1><a href="#">解答</a></h1>
                            <form action="<?php echo url_for('worry/create_answer'); ?>" method="post" class="HuiForm" onSubmit="return CheckForm();">
                                <textarea name="content" id="content-t"></textarea>
                                <input type="hidden" name="worry_id" value="<?php echo $worry->getId(); ?>" />
                                <input type="submit" value="回复">
                            </form>
                        </div>
                        <?php endif; ?>
                    <?php endif; ?>               
                <?php endif; ?>
            </div>
            <?php include_component('worry', 'comment_list',array('worry'=>$worry)); ?>
        </div>
        
        <!--右边-->
        <div class="DeRight">
            
             <?php if($sf_user->isAuthenticated()): ?>
                <?php if(!$worry->isAttenthion()): ?>
                    <div class="Gzhuwt">
                        <a href="javascript:void(0);" id="attention" attenthon="0" worry_id="<?php echo $worry->getId(); ?>">关注问题</a>
                    </div>
                    <?php elseif($worry->getUserId() != $sf_user->getAttribute('user_id')): ?>
                        <div class="Gzhuwt">
                            <a href="javascript:void(0);" id="attention" attenthon="1" worry_id="<?php echo $worry->getId(); ?>">取消关注</a>
                        </div>
                <?php endif; ?>
             <?php else: ?>
                <div class="Gzhuwt">
                    <a href="#" id="attention" worry_id="<?php echo $worry->getId(); ?>" attenthon="0">关注问题</a>
                </div>
            <?php endif; ?>
            <div class="Gzhutx"><span id="attention_people_num"><?php echo $worry->getAttentionNum(); ?></span> 人关注该问题</div>
            <div class="Gzhuren" id="attention_people">
                <?php foreach($worry->getAttentions() as $attenthion): ?>
            	<li><img src="<?php echo $attenthion->getUserCover(); ?>" width="38" height="38"></li>
                <?php endforeach; ?>
            </div>
            
        	<?php include_component('worry', 'relevance',array('worry'=>$worry)); ?>
            
        </div>
        
    </div>
<script type="text/javascript">
<?php if($sf_user->hasFlash('error') ): ?>
layer.msg('<?php echo $sf_user->getFlash('error'); ?>');
<?php endif; ?>
<?php if($sf_user->hasFlash('success')): ?>
layer.msg('<?php echo $sf_user->getFlash('success'); ?>');
<?php endif; ?>

function layerOper(url){
	//宽高
	var width = 500,
		height = 180;
	
	layer.open({
                scrollbar: false,
		type: 1,
		title: false, //标题，若不要直接false
		area: [width+'px', height+'px'], //宽高
		content: '<iframe width="100%" height="'+height+'" frameborder="0" src="'+url+'"></iframe>'
                
	});
        
        return false;
}

$(document).ready(function(){
    
    $("#attention").on('click',function(){
        var att_button = $(this);
        var w_id = $(this).attr('worry_id');
        var is_attenthion = $(this).attr('attenthon');
        var url = '';
        var text = '',attenthon = 0;
//        console.log(is_attenthion);
        
        if(is_attenthion == 0){
            url = "<?php echo url_for('worry/attention'); ?>";
            text = '取消关注';
            attenthon = 1;
        }else{
            url = "<?php echo url_for('worry/unattention'); ?>";
            text = '关注问题';
            attenthon = 0;
        }
        
        $.post(url,{"worry_id":w_id},function(data){
            var msg = eval("("+data+")");
            
            if(msg.error == 0){
                att_button.text(text).attr('attenthon',attenthon);
                var num = msg.data.people_num;
                var people = msg.data.people;
                $("#attention_people_num").text(num);
                var html = '';
                
                for(var i in people){
                    html += '<li><img src="'+people[i]+'" width="38" height="38"></li>';
                }
                
                $("#attention_people").html(html);
            }
            alert(msg.msg);
        });
        
    });
    
});


function CheckForm(){
        var content = jQuery.trim($('#content-t').val());

        if(content.length<=0){
                layer.msg('写点什么吧！');
                return false;
        }

        return true;
}

</script>